﻿//
// Created by jsyf_cc on 2025/5/16.
//

#include "SimpleRWFile.h"

#include <QDebug>
#include <QFile>

QByteArray SimpleRWFile::read(QString fileName) {
  QFile file(fileName);
  if (!file.open(QIODevice::ReadOnly)) {
    return {};
  }
  QByteArray data = file.readAll();
  return data;
}

QString SimpleRWFile::readStr(QString fileName) {
  return read(fileName);
}

bool SimpleRWFile::write(QString fileName, QByteArray content) {
  QFile file{fileName};
  if (file.open(QIODevice::WriteOnly)) {
    auto wSize = file.write(content);
    if (wSize != content.size()) {
      return false;
    }
    return true;
  }
  return false;
}